"use strict";
function imgSrc(str,src, alt) {
	let index = src.lastIndexOf("/");
	let name = src.substring(0,index);
	// https://gitee.com/feigeCode/notes/raw/master/Springboot/springboot%E8%87%AA%E5%8A%A8%E9%85%8D%E7%BD%AE%E5%8E%9F%E7%90%86/1602835786727-28b6f936-62f5-4fd6-a6c5-ae690bd1e31d.png
	if (name.indexOf("Gin") != -1|| name.indexOf("go") != -1){
		name = "Golang"
	}else if (name.indexOf("Eureka") != -1 || name.indexOf("OpenFeign") != -1){
		name = "springcloud"
	}else if (name.indexOf("consul") != -1 || name.indexOf("Gateway") != -1){
		name = "springcloud"
	}else if (name.indexOf("Hystrix") != -1 || name.indexOf("Ribbon") != -1 || name.indexOf("Zookeeper") != -1){
		name = "springcloud"
	}else if (name.indexOf("hymleaf") != -1 || name.indexOf("springboot") != -1){
		name = "Springboot"
	}else if (name.indexOf("net") != -1){
		name = "网络编程"
	}else if (name.indexOf("thread") != -1 || name.indexOf("并发编程") != -1){
		name = "多线程"
	}else if (name.indexOf("IDEA") != -1){
		name = "IDEA"
	}
	src = "https://gitee.com/feigeCode/notes/raw/master/" + name + "/" + src;
	return '<img data-fancybox="gallery" data-sizes="auto" data-src="' + src + '" alt="' + alt + '" class="lazyload">';
}
function imageAutoLazyloadHelper(content) {
	let str = content.replace(
		/<img.*?src="(.*?)" alt="(.*?)".*?\/?>/gi,
		imgSrc
	);
	str = str.replace(
        /src="images\//g,
		'src="https://cdn.jsdelivr.net/gh/nexmoe/nexmoe.github.io@latest/images/'
	);
	str = str.replace(
        /\.\.\/\.\.\/images\//g,
		'https://cdn.jsdelivr.net/gh/nexmoe/nexmoe.github.io@latest/images/'
	);
	return str;
}
hexo.extend.helper.register("image_auto_lazyload", imageAutoLazyloadHelper);
